from base import Base
from selenium.webdriver.common.by import By
from time import sleep

#继承基类
class SouSuoPage(Base):

    #减脂 定位元素
    jianzhi = 'new UiSelector().text("减脂“)'

    #搜素框架 定位元素
    sousuokuang = (By.XPATH,'//android.widget.TextView[@text="搜索菜谱"]')

    #输入框 定位元素
    shurukuang = (By.ID,'com.xiachufang:id/search_edit_text')

    #搜索按钮
    sousuoanniu = (By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[3]/android.widget.TextView')


    #断言
    dy = (By.ID,'com.xiachufang:id/tv_content')
    dy2 = (By.XPATH,'//android.widget.EditText[@resource-id="com.xiachufang:id/search_edit_text"]')


    def sousuoyewu(self,c):
        #定位减脂元素，并点击
        self.find_ele(self.jianzhi).click()
        sleep(2)
        # 定位搜索框元素，并点击
        self.find_ele(self.sousuokuang).click()
        sleep(2)
        # 定位输入框元素，并点击
        self.find_ele(self.shurukuang).send_keys(c)
        sleep(2)
        # 定位搜素按钮元素，并点击
        self.find_ele(self.sousuoanniu).click()
        sleep(2)